package constructer

import "sync"

var instance *I18nDict

func Instance() *I18nDict {
	sync.OnceFunc(func() {
		if instance == nil {
			instance = new(I18nDict)
			instance.storage = make(map[I18nDictKey]string)
		}
	})()
	return instance
}

type I18nDict struct {
	storage map[I18nDictKey]string
	rw      sync.RWMutex
}

type I18nDictKey struct {
	Key      string
	Language string
}

func (i *I18nDict) Put(key, language, value string) {
	i.rw.Lock()
	defer i.rw.Unlock()
	i.storage[I18nDictKey{Key: key, Language: language}] = value
}
